﻿@model Topic
@{
	ViewBag.Title = Model.Title;
	ViewBag.HasPostAccess = Model.HasPostAccess(Role);
}
@section Head{
	@Html.MetaDescription(Utils.Summarize(Utils.RemoveTags(Model.Description), 160, ""))
}
<ul class="path">
	<li class="first">@Html.ActionLinkLocalized("Forums", "List", "Forums")</li>
	<li>@Html.ActionLink(Model.Forum.Name, "Detail", "Forums", new{forum=Model.Forum.ShortName}, null)</li>
</ul>
<div class="topicDetail">
	<h1>@ViewBag.Title</h1>
	<div class="options">
		<a rel="nofollow" href="@Url.Action("LatestMessages")">@Html.Img("~/images/iconrss.gif", "rss")</a>
	</div>
	<p class="info">
		@T("Posted by") <strong class="userName">@Html.ActionLink(Model.User.UserName, "Detail", "Users", new{id=Model.User.Id}, new{rel="nofollow"})</strong>
		-
		@Html.Date(Model.Date)
	</p>
	<div class="description">
		@Html.Raw(Model.Description)
	</div>
@{
	var messages = new PagedList<Message>(Model.Messages, this.PageIndex, Config.UI.MessagesPerPage);
}
	@if (messages.Count > 0)
	{
		<ul id="messages">
		@foreach (Message m in messages)
		{
			Html.RenderPartial("MessageItem", m);
		}
		</ul>
	}
	@if (messages.TotalItemCount > 0)
	{
		<div class="pagerSummary">
			@T("Displaying <span class=\"firstItem\">{0}</span> to <span class=\"lastItem\">{1}</span> of <span class=\"totalItems\">{2}</span> messages",
				this.PageIndex * Config.UI.MessagesPerPage + 1,
				this.PageIndex * Config.UI.MessagesPerPage + messages.Count,
				messages.TotalItemCount)
		</div>
	}
	<div id="pagerClient" style="display:none;"><a href="#" onclick="pager.more();return false;">@Html.Img("~/images/loadingMini.gif", "") @T("Show more messages")</a></div>
	@Html.Pager(messages)
	@Html.Partial("Toolbar")
	@Html.Partial("Related")
</div>
@Html.Script("~/scripts/overtip.js")
@Html.Script("~/scripts/pager.js")
@Html.Script("~/scripts/quoting.js")
<script type="text/javascript">
	$(document).ready(function ()
	{
		quoting.init();
		pager.init('@Url.Action("PageMore", "Topics", new{id=Model.Id})', '@Url.Action("PageUntil", "Topics", new{id=Model.Id})', '@T("The browser has lost session, click ok to return to the login page")');
	});
</script>
<script type="text/javascript">
	$(document).ready(function ()
	{
		$("#messages li")
			.live("tap", function () { $(this).toggleClass("over"); })
			.live("mouseenter", function () { $(this).css("background-color","").addClass("over"); })
			.live("mouseleave", function () { $(this).removeClass("over"); });
	});
	function flagMessage(mid, url)
	{
		$.post(url, { mid: mid }, function (data)
		{
			alert('@T("Thanks you, a moderator will review the message.")');
		});
		return false;
	}
	function deleteMessage(mid, url)
	{
		return deleteMessageCommon(mid, url, '@T("Are you sure you want to hide the message #{0}?")', '@T("Message removed")', null);
	}
</script>